package lu.uni.adtool.domains.rings;


/**
 * Boolean class with html representation.
 * 
 * @author Piot Kordy
 */
public class Bool implements Ring
{
  private boolean value;

  /**
   * Allocates a Boolean object representing the <code>newValue</code> argument.
   * * @param newValue
   */
  public Bool(final boolean newValue)
  {
    value = newValue;
  }

  /**
   * Returns a String object representing this Boolean's value. If this object
   * represents the value true, a string equal to "true" is returned. Otherwise,
   * a string equal to "false" is returned.
   * 
   * @return a string representation of this object.
   */
  public final String toString()
  {
    return Boolean.toString(value);
  }

  /**
   * Unicode representation.
   * 
   * @return an unicode representation of this object.
   */
  public final String toUnicode()
  {
    return Boolean.toString(value);
  }

  /**
   * Determines if this instance is value.
   *
   * @return The value.
   */
  public final boolean getValue()
  {
    return this.value;
  }
  /**
   * Logical or.
   * 
   * @param a first parameter
   * @param b second parameter
   * @return <code>a</code> or <code>b</code>
   */
  public static Bool or(final Bool a,final Bool b)
  {
    return new Bool(a.getValue() || b.getValue());
  }
  /**
   * Logical and.
   * 
   * @param a first parameter
   * @param b second parameter
   * @return <code>a</code> and <code>b</code>
   */
  public static Bool and(final Bool a,final Bool b)
  {
    return new Bool(a.getValue() && b.getValue());
  }
  /**
   * Negation.
   * 
   * @param a parameter
   * @return not <code>a</code>
   */
  public static Bool not(final Bool a)
  {
    return new Bool(!a.getValue());
  }
}
